<template>
  <div class="home-header">
    <img src="@/assets/logo.png" alt="">
    <van-dropdown-menu>
      <van-dropdown-item :modelValue="category" :options="options" @change="change"/>
    </van-dropdown-menu>
  </div>
</template>

<script lang="ts">
import { CATEGORY_TYPES } from '@/typings/home';
import { defineComponent, PropType, reactive, toRefs } from 'vue';

export default defineComponent({
  name: 'HomeHeader',
  props: {
    category: {
      type: Number as PropType<CATEGORY_TYPES>
    }
  },
  components: {
    
  },
  emits: ['setCurrentCategory'],
  setup(props, context) {
    let state = reactive({
      options: [
        {text: '全部课程', value: CATEGORY_TYPES.ALL},
        {text: 'react课程', value: CATEGORY_TYPES.REACT},
        {text: 'vue课程', value: CATEGORY_TYPES.VUE},
        {text: 'node课程', value: CATEGORY_TYPES.NODE}
      ]
    });

    function change(value:CATEGORY_TYPES) {
      context.emit('setCurrentCategory', value);
    }

    return {
      ...toRefs(state),
      change
    }
  }
});
</script>

<style lang="scss">
.home-header {
  height: 65px;
  background: #212121;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2.5%;
  position: fixed;
  top: 0;
  left: 0;
  width: 95%;

  img {
    height: 40px;
  }

  .van-dropdown-menu__title {
    color: #fff;
  }

  .van-dropdown-menu__bar {
    background: #212121;
  }
}
</style>
